<%@ page import="com.xyc.pojo.User" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.List" %>
<%@ page import="com.xyc.pojo.Song" %>
<%@ page import="com.xyc.pojo.SongList" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext" %>
<%@ page import="com.xyc.mapper.SongListMapper" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>歌单管理</title>
    <link href="css/index.css" rel="stylesheet" type="text/css"/>
    <link href="css/list.css" rel="stylesheet" type="text/css"/>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script src="js/list.js"></script>
    <style>
        table, tr, td {
            border: 1px solid #ccc;
        }

        table {
            text-align: center;
        }

        .row1 td, .row2 td, .row_hover td, .paging_row td {
            padding: 5px 10px;
            color: #666666;
            border: 1px solid #CBD6DE;
        }

        .row2 td {
            background: #ffffff;
        }

        .row1 td {
            background: #eeeeee;
        }

        .row_hover td {
            background: #FBFACE;
            color: #000000;
        }

        #quit {
            color: blue;
        }

        #quit:hover {
            cursor: pointer;
            color: #F4A460;
        }

        a {
            text-decoration: none;
        }
    </style>
</head>
<body>
<div>
    <div id="top">
        <p class="title">&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="index.jsp" style="cursor:pointer;">HappyMusic后台系统</a>
        </p>
        <p class="quit">&nbsp;<a href="login.html" onclick="return confirm('确认退出吗? ');quit()" id="quit">退出</a>&nbsp;&nbsp;&nbsp;
        </p>
        <p class="welcome">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;欢迎你&nbsp;<%=session.getAttribute("username")%>&nbsp;&nbsp;&nbsp;</p>
        <p id="showTime" class="showTime">&nbsp;&nbsp;</p>
    </div>
    <div id="left">
        <div class="rad"><a href="admin">系统设置</a></div>
        <div class="rad"><a href="myUser">用户管理</a></div>
        <div class="rad"><a href="mySong">歌曲管理</a></div>
        <div class="rad"><a href="myList">歌单管理</a></div>
    </div
    <div id="right">
        <p>欢迎进入HappyMusic后台管理系统</p>
        <h1>歌单</h1>
        <a href="addList"><h2>添加新歌单</h2></a>

        <%--<input type="button" name="" id="btn" value="弹窗" onclick="pop({width:500,width:500});" />--%>
        <script type="text/javascript">$(function () {
        });</script>
        <div>
            <table>
                <tr>
                    <td>歌单名</td>
                    <td>备注</td>
                    <td>歌曲</td>
                </tr>
                <%
                    List<SongList> list = (List<SongList>) session.getAttribute("songList2");
                    for (int i = 0; i < list.size(); i++) {
                        SongList songList = list.get(i);
                %>
                <tr class="row<%=i%2+1%>">
                    <td>
                        <%=songList.getName()%>
                    </td>
                    <td>
                        <%=songList.getMemo()%>
                    </td>
                    <td>
                        <%
                            String uuid = songList.getUuid();
                            Map map = new HashMap();
                            map.put("uuid", uuid);
                            ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-dao.xml");
                            SongListMapper mapper = ctx.getBean("songListMapper", SongListMapper.class);
                            List<Song> sList = mapper.selectLast(map);
                            for (int j = 0; j < sList.size(); j++) {
                                Song s = sList.get(j);
                        %>
                        <span style="text-align: left;"><%=s.getName()%>&nbsp;</span>

                        <%}%>
                    </td>
                </tr>


                <%}%>
            </table>
        </div>

    </div>
    <div id="bottom">版权所有</div>
</div>
<script>
    function showTime() {
        var a = new Date();
        var b = a.toLocaleTimeString();
        var c = a.toLocaleDateString();
        document.getElementById("showTime").innerHTML = c + "&nbsp" + b;
    }

    setInterval(function () {
        showTime()
    }, 1000);

    function quit() {
        //防止页面后退
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });
    }
</script>
</body>
</html>